﻿Public Class frmGhiNhanThueNha

    Private Sub frmGhiNhanThueNha_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        dtNgayThue.Value = Date.Now

        Dim dt As DataTable = New DataTable()
        dt = KhachThueBUS.LayDSMaKhach()
        cbxKhachThue.DataSource = dt
        cbxKhachThue.DisplayMember = "MaKhachThue"

        Dim dt1 As DataTable = New DataTable()
        dt1 = NhaBUS.LayDSMaNha()
        cbxMaNha.DataSource = dt1
        cbxMaNha.DisplayMember = "MaNha"
    End Sub

    Private Sub btnGhiNhan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGhiNhan.Click
        If TT_ThueNhaBUS.KiemTraDayDu(txtGiaNha.Text) Then
            Dim tt_thue As TT_ThueNhaDTO = New TT_ThueNhaDTO()

            tt_thue.strMaKhachThue = cbxKhachThue.Text
            tt_thue.strMaNha = cbxMaNha.Text
            tt_thue.dNgayThue = dtNgayThue.Value
            tt_thue.iGia = txtGiaNha.Text

            TT_ThueNhaBUS.Insert(tt_thue)

            MessageBox.Show("Bạn đã ghi nhận thành công thông tin thuê nhà!", "THÔNG BÁO")
        Else
            MessageBox.Show("Bạn chưa nhập đủ thông tin cần thiết!", "THÔNG BÁO")
        End If
    End Sub

    Private Sub btnHuy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHuy.Click
        Me.Close()
        Form1.maintab.Tabs.RemoveAt(Form1.maintab.SelectedTabIndex)
        If Form1.maintab.Tabs.Count = 0 Then
            Form1.maintab.Visible = False
        End If
    End Sub
End Class